<template>
  <el-cascader
    :value="value"
    :options="options"
    style="width:300px"
    separator="-"
    size="mini"
    :props="{label:'name',value:'id'}"
    @change="$emit('input',$event[$event.length-1])"
  />
</template>

<script>
import { getDespAPi } from '@/api/department'
import { list2Tree } from '@/utils'
export default {
  props: {
    value: {
      type: Number,
      default: null
    }
  },
  data() {
    return {
      options: []
    }
  },
  async created() {
    // 调接口 转树
    const res = await getDespAPi()
    this.options = list2Tree(res.data, 0)
  }
}
</script>

<style>

</style>
